<?php 
if(KT!='KhiThe') exit;
class manufacturers_model extends khithe_mysql{

	public function getManufacturers($ID)
	{
		$ID = parent::checkStrMySQL($ID);
		$w  = $ID!=0?" WHERE ID = '".$ID."' ":'';
		$select = "SELECT * FROM ".manufacturers." ".$w." ORDER BY `Order` ASC";
		return parent::SelectMySQL($select);
	}
	
	public function getManufac($ID)
	{
		$ID = parent::checkStrMySQL($ID);
		$select = "SELECT * FROM ".manufacturers." WHERE ID = '".$ID."'";
		parent::CloseConnection();
		return parent::SelectMySQL($select);
	}
	
	public function setCheckedManufac($ID,$Val)
	{
		$ID = parent::checkStrMySQL($ID);
		$update = "UPDATE ".manufacturers." SET Status='".$Val."'  WHERE ID = '".$ID."'";
		parent::CloseConnection();
		return parent::UpdateInsertMySQL($update);
	}
	
	public function delCheckedManufac($ID)
	{
		$ID = parent::checkStrMySQL($ID);
		$del = "DELETE FROM ".manufacturers." WHERE ID='".$ID."' ";
		parent::CloseConnection();
		return parent::DeleteMySQL($del);
	}
	
	public function updateInsertCat($_POST)
	{
		$ID = parent::checkStrMySQL($_POST['ManufacturersID']);
		$Manufacturers = parent::checkStrMySQL($_POST['ManufacturersName']);
		$Order = parent::checkStrMySQL($_POST['CatOrder']);
		$PrentID = parent::checkStrMySQL($_POST['parentCatID']);
		
		if($this->valUrl(1)=='edit'){
			$query = "UPDATE ".manufacturers." SET Manufacturer='".$Manufacturers."',`Order`='".trim($Order)."' WHERE ID = '".trim($ID)."'";
		
		}else if($this->valUrl(1)=='add'){
			$query = "INSERT INTO ".manufacturers."(Manufacturer,`Order`)VALUES('".$Manufacturers."','".trim($Order)."')";
		}
		
		return parent::UpdateInsertMySQL($query);
		
	}
}
?>